<%-- 
    Document   : insert2
    Created on : 2014/8/19, 下午 02:05:56
    Author     : LENOVO
--%>

<%@page import="java.sql.Statement"%>
<%@page import="java.sql.Connection"%>
<%@page import="java.sql.DriverManager"%>
<%@page contentType="text/html" pageEncoding="UTF-8"%>

<%
    String username = request.getParameter("username");
    String tel = request.getParameter("tel");
    String birthday = request.getParameter("birthday");
    Class.forName("com.mysql.jdbc.Driver");
    Connection con=DriverManager.getConnection("jdbc:mysql://localhost:3306/javadb","root","root");
    Statement st = con.createStatement();
    String sql ="insert into person(username , tel , birthday) values('"+username+"' , '"+tel+"' , '"+birthday+"')";
    System.out.println(sql);
    int x = st.executeUpdate(sql);
    st.close();
    con.close();
%>
<!DOCTYPE html>
<html>
    <head>
        <meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
        <title>JSP Page</title>
    </head>
    <body>
        <h1>Hello World!</h1>
        新增 <%= x %> 筆資料 <br>
        <a href="insert1.jsp">繼續新增</a> <br>
        <a href="list.jsp">清單</a>
    </body>
</html>
